package com.sc.ifs.cart;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.sc.dal.common.pagination.Page;
import com.sc.dal.common.pagination.PaginationBean;
import com.sc.dal.mapper.cart.CartMapper;
import com.sc.dal.model.cart.Cart;
import com.sc.dal.model.cart.CartItem;
import com.sc.dal.model.cart.Shop;
import com.sc.dal.model.favorites.Favorites;
import com.sc.dal.model.goods.GoodsStock;
import com.sc.service.cart.CartService;
import com.sc.service.favorites.FavoritesService;
import com.sc.service.goods.GoodsService;
import com.sc.service.goods.GoodsSkuService;
import com.sc.service.member.MemberService;
import com.sc.util.adapter.ConfigBeanAdapter;
import com.sc.util.data.Common;
import com.sc.util.data.Constants;
import com.sc.util.data.DataUtil;
import com.sc.util.exception.ExceptionEnum;
/**
 * @ClassName: AppCartController
 * @Description: 购物车管理
 * @author LeiJia
 * @date 2017年3月8日 下午1:59:26
 * @version V1.0
 */
@Controller
@RequestMapping("/app/cart")
public class AppCartController {
	
	private final Logger logger = LoggerFactory.getLogger(this.getClass());	
	
	@Autowired
	private CartService cartService;
	
	@Autowired
	private FavoritesService favoritesService;	
	
	@Autowired
	private GoodsService goodsService;
	
	@Autowired
	private GoodsSkuService goodsSkuService;

	@Autowired
	private MemberService memberService;
	
	/**
	 * @Title  getGoodsStockBySkuValues
	 * @Description:根据商品规格值获取商品库存
	 * @param goods_sku_info
	 * @return
	 */
	@RequestMapping(value="getGoodsStockBySkuValues",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> getGoodsStockBySkuValues(Integer productId,String goods_sku_info){
		Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
		try{
			if( productId == null){
				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PRODUCT_ID_IS_NOT_NULL);
				return resultMap;
		    }

			String[] skuInfoArrs = {};
			if(Common.isNotEmpty(goods_sku_info)){
				skuInfoArrs = goods_sku_info.split(",");
			}

			GoodsStock stock = new GoodsStock();
			stock.setGoodsId(productId);
			int productStock = goodsService.getProductStock(stock,skuInfoArrs);	
		/*	for(String sku_value :skuInfoArrs){
				sku_value = sku_value.split(":")[1];
				GoodsStock stock = new GoodsStock();
				stock.setGoodsId(productId);
				stock.setSkuValue(sku_value);;
				Integer baseQuantit = cartService.selectBaseQuantity(stock);
				Integer saleBaseQuantity = cartService.selectSaleBaseQuantity(stock);
				if(baseQuantit == null || saleBaseQuantity == null){
					productStock =0;
				}
				productStock += baseQuantit-saleBaseQuantity;
			}*/
			resultMap.put("productId", productId);
			resultMap.put("goods_sku_info", goods_sku_info);
			resultMap.put("stock", productStock);
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS);
		}catch(Exception e){
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SELECT);
		}
		return resultMap;
	}
	
	/**
	 * @Title: getCart
	 * @Description:获取购物车
	 * @param mid
	 * @date 2017年3月8日下午1:13:05
	 * @author LeiJia  
	 * @return Map<String,Object>    返回类型
	 */
	@RequestMapping(value="/getCart",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> getCart(String memberId){
		Map<String, Object> resultMap = new LinkedHashMap<String, Object>();	
		if(Common.isEmpty(memberId)){				
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
			return resultMap;
	    }
		List<Shop> shops = null;
		CartItem cart = new CartItem();
		// 添加查询条件
		cart.setMemberId(memberId);
		List<CartItem> resultList = new ArrayList<CartItem>();
		try {
			shops = cartService.cartShopList(cart);
		//	resultList = cartService.selectByParam(cart);
			for(int i =0; i < shops.size(); i++){
				Shop shop = shops.get(i);
				if(shop.getCartItems() != null && shop.getCartItems().size() == 0){
					shops.remove(shop);
					continue;
				}
				resultList = shop.getCartItems();

				//根据商品规格确定库存
				for (CartItem item : resultList) {
					// 根据会员的代理商等级查询代理等级的商品折扣率
					Map<String, Object> agentInfoMap = memberService
							.selectAgentInfoByMemberId(item.getMemberId());
					if (agentInfoMap != null && agentInfoMap.size() > 0) {
						if (agentInfoMap.get("discount") != null) {
							double discount = (double) agentInfoMap.get("discount");
							item.setDiscountMarketPrice(item.getMarketPrice().multiply(new BigDecimal(discount)).setScale(2, BigDecimal.ROUND_HALF_UP));
							item.setDiscountRate(discount);
						}
					}
					if (Common.isNotEmpty(item.getPicture()))
						item.setPicture(ConfigBeanAdapter.fileAccessAddress + item.getPicture());
					String skuInfos = item.getGoods_sku_info();
					String[] skuInfoArrs = {};
					if (Common.isNotEmpty(skuInfos)) {
						skuInfoArrs = skuInfos.split(",");
					}
					GoodsStock stock = new GoodsStock();
					stock.setGoodsId(item.getProductId());
					int productStock = goodsService.getProductStock(stock,skuInfoArrs);
					item.setStock(productStock + "");
					if (productStock <= 0) { //对于购物车库存为0的商品设为失效状态，对于购物车商品数量超出商品库存的商品在结算时候给予提示修改购物车数量
						// 如果对应规格零库存
						item.setIsValid(Constants.IS_VALIDB);
						Cart c = new Cart();
						c.setId(item.getId());
						c.setIsValid(Constants.IS_VALIDB);
						c.setIsDelete(Constants.IS_DELETEA);
						c.setModifyDate(new Date());
						int updateCart = cartService.updateCart(c);
						if (updateCart > 0) {
							logger.info("商品已置为无效商品!");
						}
					}

				}
			}
			
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS);
		} catch (Exception e) {
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SELECT);
			logger.error("分页查询购物车商品异常！");
		}
	
		resultMap.put("data", shops);
		return resultMap;
	}
	/**
	 * @Title: getCartByPage
	 * @Description:分页获取购物车
	 * @param mid
	 * @date 2017年3月8日下午1:13:05
	 * @author LeiJia  
	 * @return Map<String,Object>    返回类型
	 */
	@RequestMapping(value="/getCartByPage",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> getCartByPage(Integer currPage,Integer pageSize, String memberId){
		Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
		Page page = new Page();
		// 传入页号
		page.setCurrPage(currPage);
		// 传入每页记录数
		page.setPageSize(pageSize);
		
		CartItem cart = new CartItem();
		// 添加查询条件
		cart.setMemberId(memberId);
		List<Shop> shops = new ArrayList<Shop>();
		List<CartItem> resultList = new ArrayList<CartItem>();
		int totalRecords = 0;
		int totalPage = 0;
		try {
			if(currPage == null || pageSize == null || Common.isEmpty(memberId)){				
				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
				return resultMap;
		    }
			PaginationBean<CartItem> result = cartService.getPagingDatas(cart,
					page, "count", "selectByParam",CartMapper.class);
			resultList = result.getPageList();
			//默认但店铺
			Shop shop = new Shop(Constants.SELLERID, Constants.SHOPNAME);
			Shop shop_ = new Shop("2", "某某某官网");
			List<CartItem> shop1 = new ArrayList<CartItem>();
			List<CartItem> shop2 = new ArrayList<CartItem>();
			//根据商品规格确定库存
			for( CartItem item:resultList){
				if(Common.isNotEmpty(item.getPicture()))
					   item.setPicture(ConfigBeanAdapter.fileAccessAddress + item.getPicture());
					   String skuInfos = item.getGoods_sku_info();
					if(Common.isNotEmpty(skuInfos)){
						String[] skuInfoArrs = skuInfos.split(",");
						
						int productStock = 0;
						for(String sku_value :skuInfoArrs){
							sku_value = sku_value.split(":")[1];
							GoodsStock stock = new GoodsStock();
							stock.setGoodsId(item.getProductId());
							stock.setSkuValue(sku_value);;
							Integer baseQuantit = cartService.selectBaseQuantity(stock);
							Integer saleBaseQuantity = cartService.selectSaleBaseQuantity(stock);
							if(baseQuantit == null || saleBaseQuantity == null){
								productStock =0;
							}
							productStock += baseQuantit-saleBaseQuantity;
						}
						item.setStock(productStock +"");
					}
				if(item.getSellerId().equals(Constants.SELLERID)){
					shop1.add(item);
				}else{
					shop2.add(item);
				}
				
			}
			shop.setCartItems(shop1);
			shop_.setCartItems(shop2);
			if(shop.getCartItems().size()>0)
			  shops.add(shop);
		 	if(shop_.getCartItems().size()>0)
			   shops.add(shop_);
			totalRecords = result.getTotalRecords();
			totalPage = result.getTotalPage();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS);
		} catch (Exception e) {
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SELECT);
			logger.error("分页查询购物车商品异常！");
		}
		resultMap.put("count", totalRecords);
		resultMap.put("pages", totalPage);
		resultMap.put("data", shops);
		return resultMap;
	}
	public int getProductStockBySkuValue(String sku_value){
		int result = 0;
		try{
			
		}catch(Exception e){
			e.printStackTrace();
		}
		return result;
	}
	/**
	 * @Title: addProduct
	 *  @Description:添加商品到购物车
	 * @param product_id
	 * @param goods_sku_id
	 * @param goods_sku_info
	 * @param memberId
	 * @param mount 商品的最终数量
	 * @date 2017年3月9日下午14:27:05
	 * @author LeiJia  
	 * @return Map<String,Object>    返回类型
	 */
	@RequestMapping(value="/addProduct",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> addProduct(Integer productId ,String goods_sku_id,String goods_sku_info, String memberId,Integer mount){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try{
			if(productId == null || Common.isEmpty(memberId)  || mount == null){				
				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
				return resultMap;
		    }
            Cart cart = new Cart();
            cart.setId(Common.getUUID());
            cart.setSellerId(Constants.SELLERID);
            cart.setCreateDate(new Date());
            cart.setCreater(memberId);
            cart.setIsValid(Constants.IS_VALIDA);
            cart.setSelected(Constants.CartProduct.IS_SELECTEDA);
            cart.setIsDelete(Constants.CartProduct.IS_DELETEA);
            cart.setProductId(productId);
            cart.setMemberId(memberId);
            cart.setModifier(memberId);
            cart.setModifyDate(new Date());  
            if(Common.isNotEmpty(goods_sku_id)){
                cart.setGoods_sku_id(goods_sku_id);
    			String[] goods_sku_ids = goods_sku_id.split(",");
    			String goods_sku_values="";
    			if(goods_sku_ids.length > 0){
    				for(String sku_id: goods_sku_ids){
    					Map<String,Object> paramMap = new LinkedHashMap<String, Object>();	
    					paramMap.put("goods_sku_id", sku_id);
    					paramMap = goodsSkuService.selectGoodsSkuById(paramMap);   //查询商品规格信息
    					if(paramMap != null && paramMap.size() > 0){
    						goods_sku_values += paramMap.get("base_sku_name").toString() +":"+ paramMap.get("base_sku_value_name").toString() +",";
    					}
    				}
    			}
                cart.setGoods_sku_info(goods_sku_values);
            }
			int i = cartService.addProduct(cart,mount);//处理新加入商品service层会判断是否是新增还是修改
			if(i >0){
				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS);
			}else{
				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_INSERT);
			}
		}catch(Exception e){
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_FAIL);
		}
		return resultMap;
	}	/**
	 * @Title: updateProduct
	 *  @Description:修改购物车商品数量
	 * @param id 商品购物车ID
	 * @param mount
	 * @date 2017年3月178上午09:47:05
	 * @author LeiJia  
	 * @return Map<String,Object>    返回类型
	 */
	@RequestMapping(value="/updateProduct",method=RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> updateProduct(String param){
        List<Cart> carts = null;
		
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try{
			carts =JSON.parseObject(param, new TypeReference<List<Cart>>(){});   
			if( param == null || carts == null){			
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
    			return resultMap;
			}
            for(Cart cart :carts){
            	if(Common.isEmpty(cart.getId()) || Common.isEmpty(cart.getIsMergerDelete()) || cart.getMount() == null  ){
            		
        			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
        			return resultMap;
            	}
            	Cart c = cartService.getCartByCartId(cart.getId());
            	if(c == null){
        			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
        			return resultMap;
            	}
            	if(Common.isNotEmpty(cart.getGoods_sku_id())){
                	c.setGoods_sku_id(cart.getGoods_sku_id());
        			String[] goods_sku_ids = cart.getGoods_sku_id().split(",");
        			String goods_sku_values="";
                	if(goods_sku_ids.length > 0){
        				for(String sku_id: goods_sku_ids){
        					Map<String,Object> paramMap = new LinkedHashMap<String, Object>();	
        					paramMap.put("goods_sku_id", sku_id);
        					paramMap = goodsSkuService.selectGoodsSkuById(paramMap);
        					if(paramMap != null && paramMap.size() > 0){
        						goods_sku_values += paramMap.get("base_sku_name").toString() +":"+ paramMap.get("base_sku_value_name").toString() +",";
        					}
        				}
        			}
                	c.setGoods_sku_info(goods_sku_values);
            	}
            	c .setQuantity(cart.getMount());
            	c .setIsDelete(cart.getIsMergerDelete());  
            	c.setModifyDate(new Date());
            	
            	//仿照淘宝,如果用户在编辑的情况下将购物车中不同规格的商品,编辑为购物车中同规格的商品则不再编辑这个规格
    			int i = cartService.updateCart(c);
    			if(i>0){
        			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS);
    			}else{
    				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_UPDATE);
    			}
            }
		}catch(Exception e){
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_UPDATE);
		}
		return resultMap;
	}
	
	/**
	 * @Title: deleteProduct
	 * @Description:编辑购物车删除购物车商品
	 * @param carts
	 * @date 2017年3月10日上午08:48:05
	 * @author LeiJia  
	 * @return Map<String,Object>    返回类型
	 */
	@RequestMapping(value="/deleteProduct",method=RequestMethod.POST)
	@ResponseBody
	public Map<String ,Object> deleteProduct(HttpServletRequest request,String param){
		
		List<Cart> carts = null;
		
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try{
			carts =JSON.parseObject(param, new TypeReference<List<Cart>>(){});   
			if( param == null || carts == null){			
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
    			return resultMap;
			}
            for(Cart cart :carts){
            	if(Common.isEmpty(cart.getId())){
        			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
        			return resultMap;
            	}
            	cart.setIsDelete(Constants.CartProduct.IS_DELETEB);
    			int i = cartService.deleteProduct(cart);
    			if(i>0){
        			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS);
    			}else{
    				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_DELETE);
    			}
            }
		}catch(Exception e){
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_DELETE);
		}
		return resultMap;
	}

	/**
	 * @Title: moveToFavorites
	 * @Description:编辑购物车移入收藏夹
	 * @param carts
	 * @date 2017年3月10日上午10:40:05
	 * @author LeiJia  
	 * @return Map<String,Object>    返回类型
	 */
	@RequestMapping(value="/moveToFavorites",method=RequestMethod.POST)
	@ResponseBody
	@Transactional
	public Map<String ,Object> moveToFavorites(String param){

		List<Favorites> favorites = JSON.parseObject(param, new TypeReference<List<Favorites>>(){});   
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try{
			if( param == null || favorites == null){				
    			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
    			return resultMap;
			}
            for(Favorites favorite :favorites){  
            	if( Common.isEmpty(favorite.getmId()) || Common.isEmpty(favorite.getCollectionType()) || favorite.getGoodsId() == null){				
        			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
        			return resultMap;
    			}
    			 //添加收藏
            	favorite.setCreateDate(new Date());
            	favorite.setCreater(favorite.getmId());
            	favorite.setModifier(favorite.getmId());
            	favorite.setCollectionType(Constants.CartProduct.COLLECTION_TYPEA);
            	favorite.setModifyDate(new Date());            	
            	   //添加收藏	    	
    	    	favorite.setIsDelete(Constants.CartProduct.IS_DELETEA);//商品是否要删除 是否删除（0：没有删除；1：删除）
    	    	//判断该用户是否收藏了该商品
        		Favorites f =favoritesService.selectByParam(favorite);
        		if(f != null){
        			//修改购物车商品状态
        			updateCart(favorite.getGoodsId(),favorite.getmId());
    			    continue;
        		}
            	favorite.setId(Common.getUUID());
    			int i = favoritesService.insert(favorite);
    			if(i>0){
    				//修改购物车商品状态
        			updateCart(favorite.getGoodsId(),favorite.getmId());
    				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_SUCCESS);
    			}else{
    				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_INSERT);
    			}

            }
		}catch(Exception e){
			e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_INSERT);
		}
		return resultMap;
	}
	//修改购物车商品状态
	public void updateCart(Integer productId,String memberId){
		Cart cart = new Cart();
		cart = cartService.getCartByProdcutIdAndMemberId(productId,memberId);
		if(cart != null){
    		//修改购物车商品为已添加到收藏夹，删除购物车中的该商品
			cart.setSelected(Constants.CartProduct.IS_SELECTEDB);
			cart.setIsDelete(Constants.IS_DELETEB);
			cart.setMemberId(memberId);
			int upateCartResult = cartService.updateCart(cart);
			if(upateCartResult>0){
				logger.info("商品已被收藏，购物车中该商品已移除！");
			}else{
				logger.info("商品已被收藏，购物车中该商品添加收藏失败！");
			}
		}
	}
	/**
	 * @Title: addFavorites
	 * @Description:商品详情页添加或取消商品收藏
	 * @param mId
	 * @param goodsId
	 * @param sellerId
	 * @param collectionType
	 * @param selected 商品是否已被收藏（0：否，1：是）
	 * @return
	 */
	@RequestMapping(value="/addOrCacelFavorites",method=RequestMethod.POST)
	@ResponseBody
	public Map<String ,Object> addFavorites(String mId,Integer goodsId, String sellerId, String collectionType,String selected){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		Favorites favorite = new Favorites();
		if(Common.isEmpty(mId) || Common.isEmpty(selected) || goodsId==null || Common.isEmpty(collectionType) ){
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PARAM);
			return resultMap;
		}
		favorite.setmId(mId);
		favorite.setGoodsId(goodsId); 
		favorite.setSellerId(Constants.SELLERID);   	
    	favorite.setCollectionType(collectionType);
    	favorite.setCreateDate(new Date());
    	favorite.setCreater(favorite.getmId());
    	favorite.setModifier(favorite.getmId());
    	favorite.setModifyDate(new Date()); 
    	try{

    		if(selected.equals("1")){
                //添加收藏	    	
    	    	favorite.setIsDelete(Constants.CartProduct.IS_DELETEA);//商品是否要删除 是否删除（0：没有删除；1：删除）
    	    	//判断该用户是否收藏了该商品
        		Favorites f =favoritesService.selectByParam(favorite);
        		if(f != null){
    				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PRODUCT_HAS_ADDED_FAVORITES);
    				return resultMap;
        		}
        		
    	    	favorite.setId(Common.getUUID());
    			int i = favoritesService.insert(favorite);
    			if(i>0){
        			logger.info("添加收藏夹成功！");
    				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PRODUCT_ADD_TO_FAVORITES_IS_SUCCESS);
    				return resultMap;
    			}else{
        			logger.info("添加收藏夹失败！");
    				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PRODUCT_ADD_TO_FAVORITES_IS_ERROR);
    				return resultMap;
    			}

    		
        	}else if(selected.equals("0")){
        		//取消收藏
    	    	favorite.setIsDelete(Constants.CartProduct.IS_DELETEA);//商品是否要删除 是否删除（0：没有删除；1：删除）
        		Favorites cancelF =favoritesService.selectByParam(favorite);
        		if(cancelF == null){
        			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_FAVORITES_PRODUCT_IS_NOT_FIND);
        			return resultMap;
        		}
        		cancelF.setIsDelete(Constants.FavoriteProduct.IS_DELETEB);
        		int deleteFavirteProductResult = favoritesService.updateByPrimaryKeySelective(cancelF);
        		if(deleteFavirteProductResult > 0){
        			logger.info("商品取消收藏成功！");
    				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PRODUCT_REMOVE_FROM_FAVORITES_IS_SUCCESS);
    				return resultMap;
        		}else{
        			logger.info("商品取消收藏失败 ！");
    				DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_PRODUCT_REMOVE_FROM_FAVORITES_IS_ERROR);
    				return resultMap;
        		}
        	} 
    	}catch(Exception e){
    		e.printStackTrace();
			DataUtil.handleResultMap(resultMap, ExceptionEnum.DATA_UPDATE);
    		
    	}
		return resultMap;
	}
}
